"""数据库模型包
包含所有数据库模型的定义和导出
"""
# 延迟导入避免循环导入
def get_models():
    """获取所有模型类"""
    from .enums import TaskStatus, TaskType
    from .user import User
    from .task import Task, TaskExecution
    from .system import SystemLog
    from .script import ScriptFolder, UserScript
    from .recycle import RecycleBin
    from .global_parameter import GlobalParameter
    from .common_method import CommonMethod, CommonMethodUsage
    from flask_sqlalchemy import SQLAlchemy
    
    # 创建SQLAlchemy实例
    db = SQLAlchemy()
    
    return {
        'db': db,
        'TaskStatus': TaskStatus,
        'TaskType': TaskType,
        'User': User,
        'Task': Task,
        'TaskExecution': TaskExecution,
        'SystemLog': SystemLog,
        'ScriptFolder': ScriptFolder,
        'UserScript': UserScript,
        'RecycleBin': RecycleBin,
        'GlobalParameter': GlobalParameter,
        'CommonMethod': CommonMethod,
        'CommonMethodUsage': CommonMethodUsage
    }

# 为了向后兼容，保持原有的导入方式
from flask_sqlalchemy import SQLAlchemy
db = SQLAlchemy()

# 导入所有模型
from .enums import TaskStatus, TaskType
from .user import User
from .task import Task, TaskExecution
from .system import SystemLog, SystemConfig
from .script import ScriptFolder, UserScript
from .notification import NotificationConfig
from .recycle import RecycleBin
from .global_parameter import GlobalParameter
from .common_method import CommonMethod, CommonMethodUsage

# 导出所有模型
__all__ = [
    'db',
    'TaskStatus',
    'TaskType',
    'User',
    'Task',
    'TaskExecution',
    'SystemLog',
    'SystemConfig',
    'ScriptFolder',
    'UserScript',
    'NotificationConfig',
    'RecycleBin',
    'GlobalParameter',
    'CommonMethod',
    'CommonMethodUsage'
]